﻿using AudioStudio;
using FlowCanvas.Nodes;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class Stop3DSound : CallableActionNode<string>
    {
        public override void Invoke(string audioName)
        {
            if (Play3DSound.SoundObjectMap != null)
            {
                if (Play3DSound.SoundObjectMap.TryGetValue(audioName.Trim(),out var o))
                {
                    AudioManager.StopSound(audioName.Trim(),o);
                    Play3DSound.SoundObjectMap.Remove(audioName.Trim());
                    GameObject.DestroyImmediate(o);
                }
            }
        }
    }
}